package com.huabo.dao.impl.oracle;

import com.huabo.base.BaseDaoImpl;
import com.huabo.dao.inter.LoginLogDao;
import com.huabo.model.LoginLog;
import com.huabo.sql.builder.WhereBuilder;
import com.huabo.utils.Page;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Repository;

import java.util.Map;


@Repository
public class LoginLogDaoImpl extends BaseDaoImpl<LoginLog, String> implements LoginLogDao {
	@Override
	public Page<LoginLog> queryPage(Map<String, Object> params) {
		WhereBuilder wb = new WhereBuilder();
		wb.setOrderBy("F_LOGINTIME DESC");
		if (params != null && params.size() > 0) {
			wb.andFullLike("F_NAME", params.get("name"));
			initPageParam(wb, params);

			String searchInput = (String) params.get("searchInput");
			if (StringUtils.isNotEmpty(searchInput)) {
				wb.andGroup().andFullLike("F_NAME", searchInput)
						.orFullLike("F_POLICENO", searchInput);
			}
		}
		Page<LoginLog> queryPage = queryPage(wb);
		return queryPage;
	}
}